﻿using Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    /// <summary>
    /// 权限表
    /// </summary>
    public class AuthorityDal : BaseDal<SysAuthority>
    {
        public override string tablename
        {
            get { return "SysAuthority"; }
        }

        public override Dictionary<string, bool> PKName
        {
            get
            {
                Dictionary<string, bool> dic = new Dictionary<string, bool>();
                dic.Add("authority_Id", true);
                return dic;
            }
        }
        /// <summary>
        /// 菜单列表
        /// </summary>
        /// <returns></returns>
        public List<Model.SysAuthority> AuthorityList()
        {
            string sql = "select a.*,b.Authority_Name ParentName from dbo.SysAuthority a join SysAuthority b on a.ParentId=b.Authority_Id";
            DataTable dt = Common.DBHelp.GetDataSet(sql);
            List<Model.SysAuthority> list = new List<SysAuthority>();
            foreach (DataRow item in dt.Rows)
            {
                list.Add(new Model.SysAuthority()
                {
                    authority_Id = (int)item["authority_Id"],
                    authority_Name = item["authority_Name"].ToString(),
                    authority_Url = item["authority_Url"].ToString(),
                    authority_CreatePeople = item["authority_CreatePeople"].ToString(),
                    ParentName = item["ParentName"].ToString(),
                });
            }
            return list;
        }
    }
}
